package com.briup.cms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author shaoyb
 * @program: 230308-CMS
 * @description TODO
 * @create 2023/3/13 0:30
 **/
@Configuration
// 开启对swagger的支持
@EnableSwagger2
public class Swagger2Config {
    // 配置需要扫面的controller包
    // 注意: 此处需要根据自己的包结构编写扫描路径
    // com.briup.web.controller
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.briup.cms.web.controller")).paths(PathSelectors.any())
                .build();
    }

    // swagger页面中显示的基本信息
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().
                title("包头师范团体开发").
                description("欢迎访问briup官网，http://www.briup.com")
                .termsOfServiceUrl("http://www.briup.com").
                version("1.0").build();
    }
}
